package com.springspirit.framework.message;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.builder.ToStringBuilder;

public class LogMessage implements Serializable{

	// TODO: 에러 메시지 포맷을 어떻게 정해야 할까?
	// 1. 로그인 사용자
	// 2. 로그인 IP Address
	// 3. 서브시스템(모듈)별
	// 4. 메뉴별
	// 5. 담당자별
	// 6. Layer별 (Controller, Service, Dao)
	// 7. 에러 유형별(SQLException, SystemException, BizException, and so on)
	// 8. 에러 메시지

	/**
	 * 
	 */
	private static final long serialVersionUID = -8436349672174341847L;
	
	private String id;
	private String no;
	private String loginUser;
	private String loginIpAddress;
	private String subSystem;
	private String menu;
	private String responsePerson;
	private String layer;
	private String errorCategory;
	private String timeStamp;

	private String errorMessage;

	public LogMessage() {
	};

	public LogMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public LogMessage(String id, String no, String loginUser, String loginIPAddress,
			String subSystem, String menu, String responsePerson, String layer,
			String errorCategory, String errorMessage, String timeStamp) {
		this.id = id;
		this.no = no;
		this.loginUser = loginUser;
		this.loginIpAddress = loginIPAddress;
		this.subSystem = subSystem;
		this.menu = menu;
		this.responsePerson = responsePerson;
		this.layer = layer;
		this.errorCategory = errorCategory;
		this.errorMessage = errorMessage;
		this.timeStamp = timeStamp;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

	public String getLoginUser() {
		return loginUser;
	}

	public void setLoginUser(String loginUser) {
		this.loginUser = loginUser;
	}

	public String getLoginIpAddress() {
		return loginIpAddress;
	}

	public void setLoginIpAddress(String loginIpAddress) {
		this.loginIpAddress = loginIpAddress;
	}

	public String getSubSystem() {
		return subSystem;
	}

	public void setSubSystem(String subSystem) {
		this.subSystem = subSystem;
	}

	public String getMenu() {
		return menu;
	}

	public void setMenu(String menu) {
		this.menu = menu;
	}

	public String getResponsePerson() {
		return responsePerson;
	}

	public void setResponsePerson(String responsePerson) {
		this.responsePerson = responsePerson;
	}

	public String getLayer() {
		return layer;
	}

	public void setLayer(String layer) {
		this.layer = layer;
	}

	public String getErrorCategory() {
		return errorCategory;
	}

	public void setErrorCategory(String errorCategory) {
		this.errorCategory = errorCategory;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}

	@Override
	public String toString() {

		return ToStringBuilder.reflectionToString(this);
	}
	
	public Map toMap(){
		Map map = new HashMap();
		map.put("id", id);
		map.put("no", no);
		map.put("loginUser", loginUser);
		map.put("loginIpAddress", loginIpAddress);
		map.put("subSystem", subSystem);
		map.put("menu", menu);
		map.put("responsePerson", responsePerson);
		map.put("layer", layer);
		map.put("errorCategory", errorCategory);
		map.put("errorMessage", errorMessage);
		map.put("timeStamp", timeStamp);
		
		return map;
	}

}
